import {Component, ViewChild, ViewContainerRef} from '@angular/core';
import {FieldWrapper} from '@ngx-formly/core';

@Component({
  selector: 'formly-wrapper-split',
  template: `
    <div apes-col [apesMd]="getDivCol()">
      <apes-form-item style="margin-bottom:0px;">
        <div apes-row style="padding-right:0px;">
            <apes-form-control apes-col [apesMd]="getInputCol()">
                <ng-template #fieldComponent></ng-template>
            </apes-form-control>
        </div>
      </apes-form-item>
    </div>
  `,
  host: {
    '[class.apes-formly-base]': 'true'
  }
})
export class FormlyWrapperSplit extends FieldWrapper {
  @ViewChild('fieldComponent', {read: ViewContainerRef, static: true}) fieldComponent: ViewContainerRef;

  getDivCol(){
    return this.to.col || this.to.divCol ||  24;
  }
  getInputCol(){
    return this.to.inputCol || 24;
  }
}
